<!-- 机房 - 综合表单页面 -->
<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="SuperTablePage">
    </ex_super_table_page>
    <ex_super_dialog_form ref="formDialog" :title="dialogTitle" v-bind="dialog"
      @afterSubmitSuccess="$refs['SuperTablePage'].reload()">

    </ex_super_dialog_form>
  </div>
</template>
<script>
import superTablePageFunction from '@/mixin/super-table-page-function';

export default {
  title: 'label_machine_room_manage',
  mixins: [superTablePageFunction],
  components: {},
  data() {
    return {
      option: {
        action: [
          {
            label: 'label_new_machine_room', attrs: { icon: "el-icon-plus" }, click: () => {
              this.dialogTitle = this.$tt('label_new_machine_room')
              this['$refs']['formDialog'].show(null, { setData: true })
            }
          },
        ],
        table: {
          url: "/oms-api/base/BaseMachineRoomRpc/selectAll.json",
          model: [
            {key: 'code', label: '机房编码',},
            {key: 'name', label: '机房名称',},
            {key: 'isInner', label: '是否为国内机房',},
            {key: 'ipHost', label: 'ip出口地址',},
            {key: 'contacter', label: '联系人',},
            {key: 'phone', label: '联系电话',},
            {key: 'address', label: '机房地址',},
            {key: 'wmsDomain', label: 'wms域名',},
            {key: 'printServerUrl', label: '打印服务地址',},
            {
              type: 'operate', width: 160, operate: [
                {
                  label: 'label_edit', click: (row) => {
                    this.dialogTitle = this.$tt('label_edit_machine_room')
                    this['$refs']['formDialog'].show({ "id": row["id"] },)
                  }
                },
                {
                  label: '删除',
                  type: "confirm-button",
                  url: '/oms-api/base/BaseMachineRoomRpc/remove.json',
                  message: '确定要删除该记录吗？',
                  buttonClass: "button_text_danger",
                  confirmButtonType: 'danger',
                  params: (row) => {
                    return { "id": row["id"] }
                  },
                  done: ['reload', 'tip']
                }
              ]
            }
          ],
        }
      },

      dialogTitle: '',
      dialog: {
        customClass: 'dialog_auto',
        submitUrl: '/oms-api/base/BaseMachineRoomRpc/saveUpdate.json',
        detailUrl: '/oms-api/base/BaseMachineRoomRpc/detail.json',

        form: {
          itemClass: "form_item_default", inputClass: "form_input_default",
          default: { "isInner": "Y" },
          model: [
            { header: "label_base_info", },
            { key: 'isInner', label: '是否为国内机房', type: 'select', enum: 'YesOrNoEnum' },
            { key: 'ipHost', label: 'ip出口地址', if: (formData) => formData.isInner == 'N' },
            { key: 'code', label: '机房编码', },
            { key: 'name', label: '机房名称', },
            {key: 'address', label: '机房所属地址',},
            {key: 'contacter', label: '联系人',},
            {key: 'phone', label: '联系电话',},
            {key: 'wmsDomain', label: 'wms地址',},
            {key: 'printServerUrl', label: '打印服务地址',},
          ],
          rules: {
            'code': { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
            'name': { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
            'address': { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
            'isInner': { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
            'ipHost': { required: true, pattern: /^(http:\/\/)|(https:\/\/)/, message: 'ip格式错误', trigger: 'blur' },
            'contacter': { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
            'phone': { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
          },
        }
      },
    };
  },
  methods: {}
};

</script>
<style></style>
